<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="order"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/order/save?id=${n.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
                 <label class="col-sm-2 control-label">订单编号</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="orderNo" value="${n.orderNo }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">购买用户</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="user.id" value="${n.user.id }"> --%>
                 	<input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
                 	<input type="text" class="form-control" id="user-username" name="user.username" value="${n.user.username }" 
                 		onclick="bring({
						                 	url:'${ctx}/admin/user/list',
						                 	name: 'username',
						                 	idInput: 'user-id',
						                 	nameInput: 'user-username'
						                 	})" />
                 </div>
             </div>	
			<div class="form-group" style="display:none;">
                 <label class="col-sm-2 control-label">运营商</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="operatorUser.id" value="${n.operatorUser.id }"> --%>
                 	<input type="hidden" id="operatorUser-id" name="operatorUser.id" value="${n.operatorUser.id }" class="form-control">
                 	<input type="text" class="form-control" id="operatorUser-username" name="operatorUser.username" value="${n.operatorUser.username }" 
                 		onclick="bring({
						                 	url:'${ctx}/admin/user/list',
						                 	name: 'username',
						                 	idInput: 'operatorUser-id',
						                 	nameInput: 'operatorUser-username'
						                 	})" />
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">工厂</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="factoryUser.id" value="${n.factoryUser.id }"> --%>
                 	<input type="hidden" id="factoryUser-id" name="factoryUser.id" value="${n.factoryUser.id }" class="form-control">
                 	<input type="text" class="form-control" id="factoryUser-username" name="factoryUser.username" value="${n.factoryUser.username }" 
                 		onclick="bring({
						                 	url:'${ctx}/admin/user/list',
						                 	name: 'username',
						                 	idInput: 'factoryUser-id',
						                 	nameInput: 'factoryUser-username'
						                 	})" />
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">下单时间</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="createTime" value="<fmt:formatDate value='${n.createTime }' pattern='yyyy-MM-dd HH:mm:ss'/>" onclick="laydate({format: 'YYYY-MM-DD hh:mm:ss'})">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">支付时间</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="payTime" value="<fmt:formatDate value='${n.payTime }' pattern='yyyy-MM-dd HH:mm:ss'/>" onclick="laydate({format: 'YYYY-MM-DD hh:mm:ss'})">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">发货时间</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="deliverTime" value="<fmt:formatDate value='${n.deliverTime }' pattern='yyyy-MM-dd HH:mm:ss'/>" onclick="laydate({format: 'YYYY-MM-DD hh:mm:ss'})">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">订单总额</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="amount" value="${n.amount }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">实付金额</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="actualPayAmount" value="${n.actualPayAmount }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">收件人</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="receiveName" value="${n.receiveName }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">收件人电话</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="receiveMobile" value="${n.receiveMobile }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">邮编</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="zipcode" value="${n.zipcode }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">省</label>
                 <div class="col-sm-10">
					<select name="province.id" class="form-control" id="provinceId">
						<c:forEach items="${provinces }" var="p">
						<option value="${p.id }" ${n.province.id eq p.id ? 'selected' : '' }>${p.name }</option>
						</c:forEach>
					</select>						                 	
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">市</label>
                 <div class="col-sm-10">
                 	<select name="city.id" class="form-control" id="cityId">
                 		<c:if test="${not empty(n.city.id) }">
                 		<option value="${n.city.id }">${n.city.name }</option>
                 		</c:if>
					</select>	
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">地区</label>
	                <div class="col-sm-10">
	                 	<select name="district.id" class="form-control" id="districtId">
		                 	<c:if test="${not empty(n.district.id) }">
		                 		<option value="${n.district.id }">${n.district.name }</option>
	                 		</c:if>
						</select>
	                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">详细地址</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="address" value="${n.address }">
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">支付状态</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="payStatus" value="${n.payStatus }"> --%>
                 	${enum:detail('PayStatus', 'payStatus', n.payStatus) }
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">发货状态</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="status" value="${n.status }"> --%>
                 	${enum:detail('OrderStatus', 'status', n.status) }
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">支付方式</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="payType" value="${n.payType }"> --%>
                 	${enum:detail('PayType', 'payType', n.payType) }
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">物流公司</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="expressCompany" value="${n.expressCompany }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">物流单号</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="expressNo" value="${n.expressNo }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">运营商备注</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="operatorRemark" value="${n.operatorRemark }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">工厂备注</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="factoryRemark" value="${n.factoryRemark }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">发票类型</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="invoiceType" value="${n.invoiceType }"> --%>
                 	${enum:detail('InvoiceType', 'invoiceType', n.invoiceType) }
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">发票抬头</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="invoiceTitle" value="${n.invoiceTitle }">
                 </div>
             </div>	
        	
		</form>
</div>

<%@include file="/common/foot.jsp" %>
<script type="text/javascript">
$('#provinceId').change(function() {
	var provinceId = $(this).val();
	$('#cityId').html('');
	$('#districtId').html('');
	if (provinceId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?provinceId=" + provinceId,
			dataType: "json",
			success: function(array) {
				$('#cityId').append('<option value="">城市</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#cityId').append(option);	
				}
			}
		});
	}
	
});

$('#cityId').change(function() {
	var cityId = $(this).val();
	$('#districtId').html('');
	if (cityId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?cityId=" + cityId,
			dataType: "json",
			success: function(array) {
				$('#districtId').append('<option value="">地区</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#districtId').append(option);	
				}
			}
		});
	}
	load_filter_user();
});

$('#districtId').change(function() {
	load_filter_user();
});

</script>
</body>
</html>
